resource "vultr_startup_script" "device_<%= obj['ID'] %>" {
    name   = "install_root_ssh_keys"
    script = "<%= obj['user_data'] %>"
}

resource "vultr_bare_metal_server" "device_<%= obj['ID'] %>" {
    hostname         = "<%= provision['HOSTNAME'] %>"
    plan             = "<%= provision['PLAN'] %>"
    region           = "<%= provision['REGION'] %>"
    os_id            = "<%= provision['OS'] %>"
    script_id        = vultr_startup_script.device_<%= obj['ID'] %>.id
    tag              = "OpenNebula - ONE_ID=<%= obj['ID'] %>"
    activation_email = false
}

output "device_<%= obj['ID'] %>_ip" {
    value = vultr_bare_metal_server.device_<%= obj['ID'] %>.main_ip
}

output "device_<%= obj['ID'] %>_id" {
    value = vultr_bare_metal_server.device_<%= obj['ID'] %>.id
}

